﻿@model List<DoAnForum.Models.Category> 
@using Ext.Net
@using Ext.Net.MVC
@{
    ViewBag.Title = "ListCategory";
    Layout = "~/Views/Shared/_Layout_Admin.cshtml";
}

@section Header
{

}
@section ToolbarSection{
    @Html.X().Button().Text("Create").Icon(Icon.ControlAddBlue).Listeners(ls => ls.Click.Handler = "showWindow('Create Category','/Category/CreateCategory',true,1,1);")
}
@* GridPanel *@

@(Html.X().GridPanel().ID("DataGridPanelCategory")
        .Title("List Category")
        .Icon(Icon.Table)
        .Frame(true)
        .TopBar(Html.X().Toolbar().ID("ToolID").Items(items =>
         {
             items.Add(new LinkButton { Text = "All", Handler = "#{DirectMethods}.CharFilterCategory('');", });

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "0-9", Handler = "#{DirectMethods}.CharFilterCategory('0');", });

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "A", Handler = "#{DirectMethods}.CharFilterCategory('A');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "B", Handler = "#{DirectMethods}.CharFilterCategory('B');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "C", Handler = "#{DirectMethods}.CharFilterCategory('C');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "D", Handler = "#{DirectMethods}.CharFilterCategory('D');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "E", Handler = "#{DirectMethods}.CharFilterCategory('E');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "F", Handler = "#{DirectMethods}.CharFilterCategory('F');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "G", Handler = "#{DirectMethods}.CharFilterCategory('G');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "H", Handler = "#{DirectMethods}.CharFilterCategory('H');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "I", Handler = "#{DirectMethods}.CharFilterCategory('I');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "J", Handler = "#{DirectMethods}.CharFilterCategory('J');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "K", Handler = "#{DirectMethods}.CharFilterCategory('K');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "L", Handler = "#{DirectMethods}.CharFilterCategory('L');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "M", Handler = "#{DirectMethods}.CharFilterCategory('M');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "N", Handler = "#{DirectMethods}.CharFilterCategory('N');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "O", Handler = "#{DirectMethods}.CharFilterCategory('O');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "P", Handler = "#{DirectMethods}.CharFilterCategory('P');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Q", Handler = "#{DirectMethods}.CharFilterCategory('Q');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "R", Handler = "#{DirectMethods}.CharFilterCategory('R');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "S", Handler = "#{DirectMethods}.CharFilterCategory('S');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "T", Handler = "#{DirectMethods}.CharFilterCategory('T');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "U", Handler = "#{DirectMethods}.CharFilterCategory('U');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "V", Handler = "#{DirectMethods}.CharFilterCategory('V');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "W", Handler = "#{DirectMethods}.CharFilterCategory('W');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "X", Handler = "#{DirectMethods}.CharFilterCategory('X');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Y", Handler = "#{DirectMethods}.CharFilterCategory('Y');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Z", Handler = "#{DirectMethods}.CharFilterCategory('Z');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarFill());
             
             items.Add(new Checkbox
             {
                 FieldLabel = "Include in-active",
                 Margins = "0 0 0 10",
                 LabelWidth = 130,
                 DirectCheckAction = "IncludeInActive"
             });
         }))

        .Store(Html.X().Store().ID("CategoryStore")
            .Model(Html.X().Model().IDProperty("CategoryId")
                .Fields(
                    new ModelField("CategoryId", ModelFieldType.Int),
                    new ModelField("CategoryName", ModelFieldType.String),
                    new ModelField("Description", ModelFieldType.String),
                    new ModelField("Level", ModelFieldType.Int),
                    new ModelField("Active", ModelFieldType.Boolean)
                )
            )
                .RemoteSort(true)
                .RemotePaging(true)
                .PageSize(15)
                    .Proxy(Html.X().AjaxProxy().Url(Url.Action("BindingCategoryStore"))
                                .Reader(Html.X().JsonReader().Root("data")))
        )
        .ColumnModel(
                    Html.X().Column().Text("CategoryName").DataIndex("CategoryName").Flex(1),
                    Html.X().Column().Text("Description").DataIndex("Description").Flex(1),
                    Html.X().Column().Text("Level").DataIndex("Level").Flex(1),  
                    Html.X().Column().Text("IsActive").DataIndex("Active").Flex(1),
                    Html.X().CommandColumn().Width(60).Commands(
                            Html.X().GridCommand().CommandName("Edit").Icon(Icon.NoteEdit).Text("Edit")
                    )
                        .Listeners(ls => ls.Command.Handler = "showWindow('Edit Category', '/Category/EditCategory/' + record.data.CategoryId, true, 1, 1);")
        )
        .SelectionModel(Html.X().CheckboxSelectionModel().RowSpan(1))
        .BottomBar(Html.X().PagingToolbar())
)
